﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevComponents.DotNetBar;
using System.Security.Cryptography;

namespace QLThueMuonXe
{
    public class HamDungChung
    {
        //mã hóa md5 cho cái mật khẩu
        public string EncodeMD5(string pass)
        {
            MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider();
            byte[] bs = System.Text.Encoding.UTF8.GetBytes(pass);
            bs = md5.ComputeHash(bs);
            System.Text.StringBuilder s = new System.Text.StringBuilder();
            foreach (byte b in bs)
            {
                s.Append(b.ToString("x2").ToLower());
            }
            pass = s.ToString();
            return pass;
        }


        //Lấy mã tiếp theo
        public string NextID(string lastID, string prefixID)
        {
            try
            {
                int nextID = int.Parse(lastID.Remove(0, prefixID.Length)) + 1;
                int lengthNumerID = lastID.Length - prefixID.Length;
                string zeroNumber = "";
                for (int i = 1; i <= lengthNumerID; i++)
                {
                    if (nextID < Math.Pow(10, i))
                    {
                        for (int j = 1; j <= lengthNumerID - i; i++)
                        {
                            zeroNumber += "0";
                        }
                        return prefixID + zeroNumber + nextID.ToString();
                    }
                }
                return prefixID + nextID;
            }
            catch { return "Lỗi"; }
        }

        private Command mofrmNV;
        public Command showfrmNhanVien
        {
            get { return mofrmNV; }
            set { mofrmNV = value; }
        }
        private Command dongfrmNV;
        public Command dongfrmNhanVien
        {
            get { return dongfrmNV; }
            set { dongfrmNV = value; }
        }

        private Command mofrmhangxe;
        public Command showfrmHangXe
        {
            get { return mofrmhangxe; }
            set { mofrmhangxe = value; }
        }
        private Command dongfrmhx;
        public Command dongfrmHangXe
        {
            get { return dongfrmhx; }
            set { dongfrmhx = value; }
        }

        private Command mofrmxe;
        public Command showfrmXe
        {
            get { return mofrmxe; }
            set { mofrmxe = value; }
        }
        private Command dongfrmx;
        public Command dongfrmXe
        {
            get { return dongfrmx; }
            set { dongfrmx = value; }
        }

        private Command mofrmgiathue;
        public Command showfrmgiathue
        {
            get { return mofrmgiathue; }
            set { mofrmgiathue = value; }
        }
        private Command dongfrmgt;
        public Command dongfrmgiathue
        {
            get { return dongfrmgt; }
            set { dongfrmgt = value; }
        }

        private Command mofrmttnv;
        public Command showfrmttnv
        {
            get { return mofrmttnv; }
            set { mofrmttnv = value; }
        }
        private Command dongfrmttnv;
        public Command dongfrmttnvien
        {
            get { return dongfrmttnv; }
            set { dongfrmttnv = value; }
        }
    }
}
